﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using WpfLockScreen.Common;

namespace WpfLockScreen
{
    /// <summary>
    /// App.xaml 的交互逻辑
    /// </summary>
    public partial class App : Application
    {

        //[DllImport("user32.dll")]
        //private static extern int RegisterWindowMessage(string lpString);

        //[DllImport("user32.dll")]
        //private static extern bool ChangeWindowMessageFilter(int message, int dwFlag);

        Mutex mutex;
        /// <summary>
        /// 启动
        /// </summary>
        /// <param name="e"></param>
        protected override void OnStartup(StartupEventArgs e)
        {
            CommStatic.TargetFullName = Assembly.GetExecutingAssembly().Location;
            if (e.Args.Length >= 1)
            {
                CommStatic.Password = e.Args[0];
            }
            bool ret;
            string mutexName = "WpfScreen";
            mutex = new Mutex(true, mutexName, out ret);
            if (!ret)
            {
                Environment.Exit(0);
            }
        }
    }
}
